import request from '@/utils/request'

/**
 * 获取所有 App映射列表
 */
export function getAppMappingList() {
  return request({
    url: '/api/app/mapping/list',
    method: 'get'
  })
}

/**
 * 根据API Key获取 App映射详情
 */
export function getAppMappingByApiKey(realApiKey) {
  return request({
    url: `/api/app/mapping/info/${encodeURIComponent(realApiKey)}`,
    method: 'get'
  })
}

/**
 * 保存 App映射
 */
export function saveAppMapping(data) {
  return request({
    url: '/api/app/mapping/save',
    method: 'post',
    data
  })
}

/**
 * 更新 App映射
 */
export function updateAppMapping(data) {
  return request({
    url: '/api/app/mapping/update',
    method: 'post',
    data
  })
}

/**
 * 删除 App映射
 */
export function deleteAppMapping(realApiKey) {
  return request({
    url: `/api/app/mapping/delete/${encodeURIComponent(realApiKey)}`,
    method: 'post'
  })
}

/**
 * 更新状态
 */
export function updateAppMappingStatus(realApiKey, status) {
  return request({
    url: '/api/app/mapping/status',
    method: 'post',
    params: { realApiKey, status }
  })
}

